package com.intranet.sys.web;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.intranet.sys.service.MenuService;
import com.water.web.BaseController;

/**
 * 首页
 * 
 * @author whl
 * 
 */
@Controller
public class IndexController extends BaseController {

	@Autowired
	private MenuService menuService;

	/**
	 * 显示首页栏目
	 * 
	 * @param request
	 * @param user
	 * @return
	 */
	@RequestMapping("/index")
	public ModelAndView login(HttpServletRequest request) {
		ModelAndView mav = new ModelAndView();
		mav.setViewName("/inc/index");
		return mav;
	}

	/**
	 * URL映射
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping("/menuUrl")
	public ModelAndView menuUrl(HttpServletRequest request) {
		ModelAndView mav = new ModelAndView();
		String path = request.getParameter("name");
		String menuPath = request.getParameter("menuPath");
		try {
			if (menuPath != null && !menuPath.equals("")) {
				menuPath = new String(menuPath.getBytes("iso-8859-1"), "UTF-8");
				mav.addObject("menuPath", menuPath);
			}
		} catch (UnsupportedEncodingException e) {
		}
		mav.setViewName(path);

		return mav;
	}
}
